/**
 * @FileDescription 企业api
 * @Author 祝小文
 * @CreateDate 2022-10-11 02:55
 */
import { chemical_server as request } from '@/service'

interface ResultType {
  result: {
    resultCode: string
    resultMessage: string
  }
  data: object
}

/** 适配接口返回结果 */
function adapter(response: ResultType) {
  if (response.result.resultCode == '000000') {
    return response.data
  }
  throw new Error()
}

/** 企业API Start */
//获取 企业信息
export const queryQyxxInfo = (params?: any) =>
  request.get(`/qyxx/queryQyxxInfo`, { params }).then((res) => adapter(res as any))

/**
 * 根据id 查询联系人信息
 */
export const queryContactInfo = (params?: any) =>
  request.get(`/fzrxx/queryFzrxxInfo`, { params }).then((res) => adapter(res as any))

//新增/修改 企业信息
export const insertOrUpdateQyxx = (params?: any) =>
  request.post(`/qyxx/insertOrUpdate`, params).then((res) => adapter(res as any))

//新增或修改联系人信息
export const insertOrUpdateLxrxx = (params?: any) =>
  request.post(`/fzrxx/insertOrUpdate`, params).then((res) => adapter(res as any))
//新增或修改附件信息
export const insertOrUpdatefjxx = (params?: any) =>
  request.post(`/fjxx/insertOrUpdate`, params).then((res) => adapter(res as any))

export const queryyqList = (params?: any) =>
  request.get(`/zd-zdmc/queryYqxxZdInfo`, { params }).then((res) => adapter(res as any))

//附件查询
export const queryfjList = (params?: any) =>
  request.get(`/fjxx/queryFjxxInfo`, { params }).then((res) => adapter(res as any))
//附件查询
export const querycyl = (params?: any) =>
  request.get(`/zd-zdmc/queryCylZdInfo`, { params }).then((res) => adapter(res as any))

/** 企业API End */
